Skip to content

Conversation

@justin808
Copy link
Member

@justin808 justin808 commented Oct 9, 2025

Summary

  • Enhanced error message when swap-deps encounters missing directory paths
  • Provides helpful guidance on how to fix the issue (update config or use --restore)

Changes

  • Updated validate_local_paths! to provide a more informative error message that includes:
    • The path that doesn't exist
    • Common causes (outdated config, deleted repo)
    • Suggested fixes

Test plan

  • All existing tests pass
  • RuboCop passes
  • Minimal change - only the error message is improved

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved error message when a local dependency path is missing. Users now see a clear, multi-line explanation with likely causes (e.g., outdated path, moved/deleted repo) and actionable steps to resolve (update configuration or restore).
    • Provides guidance to quickly correct .swap-deps.yml entries or use the restore option, reducing confusion and speeding up troubleshooting.

When swap-deps encounters a missing directory path (e.g., a deleted
Conductor workspace), it now provides a helpful error message that:

- Clearly states which path doesn't exist
- Explains common causes (outdated .swap-deps.yml, deleted repo)
- Suggests fixes (update config or use --restore)

This makes the tool more user-friendly when dealing with stale
configuration files that reference non-existent paths.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@coderabbitai
Copy link

coderabbitai bot commented Oct 9, 2025

Walkthrough

Updated error messaging in lib/demo_scripts/gem_swapper.rb by replacing a terse raise with a constructed multi-line, contextual error message in validate_local_paths!. No changes to control flow, signatures, or other logic.

Changes

Cohort / File(s) Summary
Error message refinement
lib/demo_scripts/gem_swapper.rb
Replaced simple raise with detailed, multi-line error message in validate_local_paths! explaining missing local gem path causes and remediation steps. No logic or flow changes.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Poem

A gem went missing—oh dear, what a hop!
I traced the burrow to a path that did stop.
Now clearer signs guide my cotton-tail trail,
With multi-line hints that never fail.
Carrot in paw, I debug and bop—
Paths found, gems bound, hippity-hop! 🥕✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title clearly and concisely describes the primary change of the pull request, namely enhancing the swap-deps command’s error handling for missing directories, and directly reflects the improvements outlined in the PR summary without introducing extraneous details.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-swap-deps-error-only

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@claude
Copy link

claude bot commented Oct 9, 2025

Code Review - PR #47: Improve swap-deps error handling for deleted directories

Overview

This PR enhances the error message in the validate_local_paths! method to provide more helpful guidance when local gem paths don't exist. The change is focused, minimal, and valuable.

Strengths

  1. Excellent UX Improvement: The enhanced error message provides actionable guidance that will help developers quickly resolve the issue without needing to dig through documentation.

  2. Code Quality:

    • Clean, readable implementation
    • Follows Ruby string concatenation patterns
    • Maintains consistency with the codebase style
  3. Test Coverage: The existing test at spec/demo_scripts/gem_swapper_spec.rb:251-258 validates this method and will continue to work with the enhanced message.

  4. Low Risk: The change only affects error messaging, not logic or control flow.

Minor Suggestions

1. String Building Performance

The current implementation uses multiple string concatenations with +=. While this works fine for error messages (which are rarely constructed), consider using a heredoc for slightly better readability. This is purely stylistic and not blocking.

2. Test Update Consideration

The test at gem_swapper_spec.rb:256 checks for the error message pattern. The regex pattern should still match, but you may want to add assertions to verify the enhanced message content is present.

Security

No security concerns. The change only affects error messaging and doesn't introduce any vulnerabilities.

Bugs

No bugs identified.

Performance

No performance impact. Error messages are only constructed when validation fails.

Test Coverage

Adequate coverage exists at gem_swapper_spec.rb:243-259. The test validates the error is raised with appropriate messaging.

Verdict

APPROVED - This is a solid quality-of-life improvement. The suggestions above are optional enhancements, not blockers. The PR is ready to merge as-is.

Great work improving the developer experience!


Review generated with Claude Code

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
lib/demo_scripts/gem_swapper.rb (1)

522-530: Excellent improvement to error messaging!

The enhanced error message is clear, actionable, and user-friendly. It provides context about what went wrong and offers concrete solutions.

Consider using a heredoc for better readability and efficiency:

-        error_msg = "Local path for #{gem_name} does not exist: #{path}\n\n"
-        error_msg += "This usually means:\n"
-        error_msg += "  1. The path in .swap-deps.yml is outdated\n"
-        error_msg += "  2. You moved or deleted the local repository\n\n"
-        error_msg += "To fix:\n"
-        error_msg += "  - Update .swap-deps.yml with the correct path\n"
-        error_msg += '  - Or use --restore to restore original dependencies'
+        error_msg = <<~ERROR_MSG
+          Local path for #{gem_name} does not exist: #{path}
+
+          This usually means:
+            1. The path in .swap-deps.yml is outdated
+            2. You moved or deleted the local repository
+
+          To fix:
+            - Update .swap-deps.yml with the correct path
+            - Or use --restore to restore original dependencies
+        ERROR_MSG
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4ee628c and 5d9fef3.

📒 Files selected for processing (1)
  • lib/demo_scripts/gem_swapper.rb (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: claude-review

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
lib/demo_scripts/gem_swapper.rb (1)

522-530: Excellent error message improvement!

The enhanced error message provides clear context, common causes, and actionable fixes. This will significantly improve the user experience when encountering missing gem paths.

Optional: Consider using a heredoc for cleaner multi-line string construction:

-        error_msg = "Local path for #{gem_name} does not exist: #{path}\n\n"
-        error_msg += "This usually means:\n"
-        error_msg += "  1. The path in .swap-deps.yml is outdated\n"
-        error_msg += "  2. You moved or deleted the local repository\n\n"
-        error_msg += "To fix:\n"
-        error_msg += "  - Update .swap-deps.yml with the correct path\n"
-        error_msg += '  - Or use --restore to restore original dependencies'
-
-        raise Error, error_msg
+        error_msg = <<~ERROR_MSG
+          Local path for #{gem_name} does not exist: #{path}
+
+          This usually means:
+            1. The path in .swap-deps.yml is outdated
+            2. You moved or deleted the local repository
+
+          To fix:
+            - Update .swap-deps.yml with the correct path
+            - Or use --restore to restore original dependencies
+        ERROR_MSG
+
+        raise Error, error_msg
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4ee628c and 5d9fef3.

📒 Files selected for processing (1)
  • lib/demo_scripts/gem_swapper.rb (1 hunks)

@justin808 justin808 requested a review from Copilot October 9, 2025 22:31
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR improves error handling in the swap-deps tool by providing more helpful error messages when local dependency paths are missing. Instead of a brief error message, users now receive detailed guidance on likely causes and actionable solutions.

  • Enhanced error message formatting with multi-line explanations
  • Added context about common causes (outdated paths, moved/deleted repositories)
  • Provided clear remediation steps (update config or use --restore)

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@justin808 justin808 merged commit 0bfb7be into main Oct 9, 2025
5 checks passed
@justin808 justin808 deleted the fix-swap-deps-error-only branch October 9, 2025 22:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants